package com.xbao.model.req;

import java.io.Serializable;

/**
 * 分页对象
 */
public class Pager implements Serializable{
    //分页类型(pageNo分页方式，适用于数据量变化不大的情况)
    public final static int TYPE_PAGE_NO = 0;
    //分页类型(pageNum方式适用于数量量变更，新增比较频繁的数据)
    public final static int TYPE_START_NUM = 1;


    //升序
    public final static int SORT_ASC = 1;
    //降序
    public final static int SORT_DESC = 0;

    public Integer getStart() {
        return (pageNo - 1) * pageSize;
    }

    public Long getEnd() {
        return (long) (pageNo * pageSize - 1);
    }

    //分页类型
    public Integer pageType;

    public Long totalCount;

    public Long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Long totalCount) {
        this.totalCount = totalCount;
    }


    public Pager(Integer pageNo, Integer pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.pageType = TYPE_PAGE_NO;
    }

    public Pager(Long startNum, Integer pageSize) {
        this.startNum = startNum;
        this.pageSize = pageSize;
        this.pageType = TYPE_START_NUM;
    }

    public Integer pageNo =null;
    private Integer pageSize=null ;
    private Long startNum = -1L;
    public Pager(){

    }

    public Long getStartNum() {
        return startNum;
    }

    public void setStartNum(Long startNum) {
        this.startNum = startNum;
    }

    public Boolean isEnd() {
        return end;
    }

    public void setEnd(Boolean end) {
        this.end = end;
    }

    private Boolean end;

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Pager nextPage() {
        this.pageNo++;
        return this;
    }


    public Boolean isFristPage() {
        return pageNo == 1;
    }


}
